<template>
	<view>
		<view class="top">
			<view class="search">
				<view class="search-input">
					<text class="iconfont icon-sousuo"></text>
					<input class="text-normal" type="text" :value="searchValue" :placeholder="placeholder" @input="searchInput" />
				</view>
				<view class="btn-cancel" @click="cancelSearch">取消</view>
			</view>
		</view>
		<view class="body" >
			<template>
				<yzb-team :teams="teamList" :dayUsersNum="dayUsersNum" :usersNum="usersNum" :sumDaoliMoney="sumDaoliMoney" :upgradeMsg="upgradeMsg"></yzb-team>
			</template>
			<view class="load-more-box">
				<uni-load-more v-if="status == '请求中'" status="正在加载..." :showIcon="true"></uni-load-more>
				<uni-load-more v-if="status == '没有更多'" status="没有更多了" :showIcon="false"></uni-load-more>
				<uni-load-more v-if="status == '暂无数据'" status="暂无数据" :showIcon="false"></uni-load-more>
				<uni-load-more v-if="status == '请求失败'" status="加载失败，点我重试" :showIcon="false" @click="reLoad"></uni-load-more>
			</view>
		</view>
	</view>
</template>


<script>
	import yzbTeam from '@/components/yzb/yzb-team.vue';
	
	export default {
		components: {
			yzbTeam
		},
		data() {
			return {
				status:"",
				teamList:{},
				usersNum:0,
				dayUsersNum:0,
				upgradeMsg:"",
				sumDaoliMoney:0,
				searchValue: '',
				placeholder: '请输入会员昵称或者用户名',
			}
		},
		onLoad(options) {
			this.getTeamList();
		},
		onPullDownRefresh() {
			this.getTeamList();
		},
		onShow() {
			this.getTeamList();
			
		},
		methods: {
			
			// 修改请求状态
			changeStatus() {
				if (this.teamList.length === 0) {
					this.status = '暂无数据';
				} else {
					this.status = '没有更多';
				} 
			},
			async getTeamList(type = 'refresh', pulldown = false){
				this.status = '请求中';
				let data=await this.$apis.teamList();
				if (data) {
					if (type == 'refresh') {
						this.teamList = {};
					}
					if (pulldown) {
						uni.stopPullDownRefresh();
					}
					console.log("temp===",data.usersNum)
					this.teamList = data.list;
					this.sumDaoliMoney=data.sumDaoliMoney;
					this.upgradeMsg=data.upgradeMsg;
					//总推广人数
					this.usersNum=data.usersNum;
					//今日推广人数
					this.dayUsersNum=data.dayUsersNum;
					this.changeStatus();
				}
			}
		}
	}
</script>

<style lang="scss">
.search {
	width: 100%;
	display: flex;
	height: 90upx;
	z-index: 999;
	flex-direction: row;
	color: $font-color-999;
	align-items: center;
	justify-content: center;
	.icon-sousuo {
		color: $font-color-999;
		font-size: $uni-font-size-base;
		margin: 0 15upx;
	}
	.search-input {
		width: 77%;
		height: 65upx;
		border-radius: 50upx;
		display: flex;
		flex-direction: row;
		background-color: #ffffff;
		align-items: center;
	}
	.search-input image {
		width: 35upx;
		height: 35upx;
		margin-right: 10upx;
	}
	.search-input input {
		width: 65%;
		font-size: 28upx;
		color: $font-color-333;
	}

	.btn-search {
		margin-left: 20upx;
	}

	.btn-cancel {
		margin-left: 20upx;
	}
}
</style>
